// -----------------------------------------------------------------
// Card
// -----------------------------------------------------------------

.LiveMemory-Card {
  --card-radius: 8%;

  display: grid;
  aspect-ratio: 1 / 1;
  justify-self: center;
  cursor: pointer;
  max-inline-size: 14rem;
  width: 100%;
  position: relative;
  perspective: 1000px;

  transform-style: preserve-3d;
  transform-origin: center;
  transition-duration: 750ms;
}

.LiveMemory-Card--flipped {
  transition: transform 1200ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transition-duration: 800ms;
  transform: rotateY(180deg);
}

.LiveMemory-Card__face {
    position: absolute;
    inset: 0;
    display: grid;
    padding: 1rem;
    justify-content: center;
    align-items: center;
    backface-visibility: hidden;
    border-radius: var(--card-radius, 1vmin);
    overflow: hidden;
}
.LiveMemory-Card__face--front {
  transform: rotateY(180deg);
}

.LiveMemory-Card__front,
.LiveMemory-Card__back {
  position: absolute;
  inset: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: var(--card-radius, 1vmin);
  overflow: hidden;
}
.LiveMemory-Card__button {
    position: absolute;
    display: block;
    inset: 0;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.LiveMemory-Card__img {
  width: 100%;
  height: auto;
}
.LiveMemory-Card:not(.LiveMemory-Card--flipped):hover {
    transform: scale(1.05);
    transition: transform 0.75s ease-in-out;
}

.LiveMemory-Card--matched {
  animation: matched 1500ms forwards linear;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
  animation-delay: 0ms;
  scale: .95;
}

.LiveMemory-Card--matched .LiveMemory-Card__front {
  border: 4px solid color-mix(in oklab, var(--live-memory-color) 50%, var(--color-text));
}

.LiveMemory-Card--matched:not(.LiveMemory-Card--paired) {
  animation-fill-mode: forwards;
}

@keyframes matched {
  0% {
    rotate: -720deg;
    scale: 1;
  }
  50% {
    scale: .55;
    filter: motionBlur(10px, 90deg);
  }
  100% {
    rotate: 0;
    scale: .95;
  }
}

.LiveMemory-CardDots {
  position: absolute;
  inset: 10%;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  rotate: calc(18deg * var(--slot-delta, 0));
}

.LiveMemory-CardDots span {
  animation: live-memory-match 1.5s ease-out;
  rotate: calc(var(--i) * 57deg);
  width: calc(var(--i) * .1rem);
  height: calc(var(--i) * .1rem);
  border-radius: 50%;
  mix-blend-mode: overlay;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
  z-index: 0;
}

@keyframes live-memory-match {
  0% {
    opacity: 0;
    transform: translateX(0);
    scale: .5;
    background: var(--live-memory-color);
  }
  5% {
    scale: 1;
  }
  20% {
    opacity: .75;
    transform: translateX(2vmin);
    scale: calc(1 + var(--i) * .1);
  }
  50% {
    opacity: .1;
    background: #fff;
  }
  100% {
    scale: calc(2 + var(--i) * .1);
    opacity: 0;
    transform: translateX(calc(var(--i) * 1vmin + 2vmin));
    background: #fff;
  }
}
